package com.lineage.server.serverpackets;

import com.lineage.server.model.Instance.L1DollInstance;
import com.lineage.server.model.Instance.L1DollInstance2;
import com.lineage.server.model.Instance.L1NpcInstance;
import com.lineage.server.model.Instance.L1PcInstance;

public class S_NPCPack_Doll extends ServerBasePacket {
  private byte[] _byte;
  
  public S_NPCPack_Doll(L1DollInstance pet, L1PcInstance pc) {
    this._byte = null;
    writeC(87);
    writeH(pet.getX());
    writeH(pet.getY());
    writeD(pet.getId());
    writeH(pet.getGfxId());
    writeC(pet.getStatus());
    writeC(pet.getHeading());
    writeC(0);
    writeC(pet.getMoveSpeed());
    writeD(0);
    writeH(0);
    writeS(pet.getNameId());
    writeS(pet.getTitle());
    writeC(0);
    writeD(0);
    writeS(null);
    if (pet.getMaster() != null) {
      if (pet.getMaster() instanceof L1PcInstance) {
        L1PcInstance master = (L1PcInstance)pet.getMaster();
        if (master.isProtector()) {
          writeS("**守护者**");
        } else {
          writeS(master.getName());
        } 
      } else if (pet.getMaster() instanceof L1NpcInstance) {
        L1NpcInstance npc = (L1NpcInstance)pet.getMaster();
        writeS(npc.getNameId());
      } 
    } else {
      writeS("");
    } 
    writeC(0);
    writeC(255);
    writeC(0);
    writeC(0);
    writeC(0);
    writeC(255);
    writeC(255);
  }
  
  public S_NPCPack_Doll(L1DollInstance2 pet, L1PcInstance pc) {
	    this._byte = null;
	    writeC(87);
	    writeH(pet.getX());
	    writeH(pet.getY());
	    writeD(pet.getId());
	    writeH(pet.getGfxId());
	    writeC(pet.getStatus());
	    writeC(pet.getHeading());
	    writeC(0);
	    writeC(pet.getMoveSpeed());
	    writeD(0);
	    writeH(0);
	    writeS(pet.getNameId());
	    writeS(pet.getTitle());
	    writeC(0);
	    writeD(0);
	    writeS(null);
	    if (pet.getMaster() != null) {
	      if (pet.getMaster() instanceof L1PcInstance) {
	        L1PcInstance master = (L1PcInstance)pet.getMaster();
	        if (master.isProtector()) {
	          writeS("**守护者**");
	        } else {
	          writeS(master.getName());
	        } 
	      } else if (pet.getMaster() instanceof L1NpcInstance) {
	        L1NpcInstance npc = (L1NpcInstance)pet.getMaster();
	        writeS(npc.getNameId());
	      } 
	    } else {
	      writeS("");
	    } 
	    writeC(0);
	    writeC(255);
	    writeC(0);
	    writeC(0);
	    writeC(0);
	    writeC(255);
	    writeC(255);
	  }

public byte[] getContent() {
    if (this._byte == null)
      this._byte = getBytes(); 
    return this._byte;
  }
  
  public String getType() {
    return getClass().getSimpleName();
  }
}
